<!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8"/>
    <title>新闻详情</title>
    <meta name="keywords" content="manager,personal,manage"/>
    <meta name="description" content="新闻,新闻详情"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <style>
        .newsTitle{
            text-align: center;
        }
        .author{
            text-align: center;
        }
        .content{
            height:500px;
            overflow: auto;
        }
    </style>
    <script src="https://cdn.bootcss.com/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<div class="page-content">
    <h1 class="newsTitle"></h1>
    <p class="author"></p>
    <div class="content"></div>
</div>
<script type="text/javascript">
    var id = window.location.href.split("?")[1].split('=')[1]
    $.ajax({
        type: 'GET',
        url: '/news/posts/getPostsDtlById?postId=' + id,
        success: function(resb) {
            console.log(resb.data);
            var time = resb.data.showDate + '000';
            $('.newsTitle').html(resb.data.postTitle);
            $('.author').html(resb.data.authors.name + '   ' + formatDate(parseInt(time)));
            $('.content').html(resb.data.postContent);
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });

    /**
     * 时间戳转换成时间
     * @param nows 转换的时间戳
     */
    function formatDate(nows) {
        var now=new Date(nows);
        var year=now.getFullYear();
        var month=now.getMonth()+1;
        var date=now.getDate();
        var hour=now.getHours();
        var minute=now.getMinutes();
        var second=now.getSeconds();
        return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
    }
</script>
</body>
</html>
